<?php
/**
 * 订单相关
 * Created by PhpStorm.
 * User: Wang YuLong
 * Date: 2018/11/28
 * Time: 8:52
 */

namespace app\api\model;

use think\Model;
use think\db;

class Indent extends Model
{
    /**
     * 查询用户订单的详细数据
     * @param $userid 用户id
     * @param $status 订单状态
     */
    public function index($data)
    {
        error_reporting(0);

        $info = Db::name('indent')
            ->alias('i')
            ->join('agency a','i.agencyid=a.id','left')
            ->join('issue g','i.issueid=g.id','left')
            ->where($data)
            ->field('i.id,a.shop,g.name,i.price,i.reality,i.number,i.audit')
            ->select();
        if(count($info) == 0)
        {
            return 0;
        }
        else
        {
            return $info;
        }
    }
    //添加订单信息
    public function adds($res){
        $data = new Indent($res);
        $arr=$data->allowField(true)->save();
        if($arr)
            return 1;
        else
            return 0;
    }

    /**
     * 统计用户的订单总数
     */
    public function countindent($info)
    {
       $data = Indent::where($info)->count();
       return $data;
    }
    /**
     * 查询一条订单信息
     */
    public function OneData($id){
        $res=$this->where('id',$id)->find();
        return $res;
    }
}